<?php
session_start();
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/class.admin.php');
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/database.php');
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/functions.php');
$admin= new admin();
$admin->canView($_SERVER['PHP_SELF']);
$seo_title=$admin->make_slug($_POST['post_title']);
$post_id=$admin->lockAndReturnUID();
$t=date("d-m-y",time());
$dates=explode("-",$t);
// find the blog URL...
$url='/blog/'.$post_id.'/'.$t.'/'.$seo_title;
$item=array(
			'text'=>'Blog post',
			'timestamp'=>intval(time()),
			'url'=>$url,
			'is_parent'=>intval(0),
			'parent'=>'',
			'active'=>intval(0),
			'include_in_nav'=>intval(0),
			'order'=>intval(100),
			'heading'=>$_POST['post_title'],
			'sidebar'=>intval(0),
			'requires_auth'=>intval(0), // work on this later
			'cache'=>intval(0),
			'is_blog'=>intval(1),
			'is_blog_post'=>intval(1),
			'post_id'=>intval($post_id),
			'content'=>$_POST['post_content'],
			'meta'=>array(			
							'keywords'=>'',
							'title'=>$_POST['post_title'],// add a date to it
							'description'=>'',
							'custom'=>''),
			'post_dates'=>array('day'=>intval($dates[0]),'month'=>intval($dates[1]),'year'=>intval($dates[2])),
			'author'=>'Admin',
			'tags'=>array()
			);
$admin->addBlogPost($item);
?>
<script>
$(".comment_field,textarea").val("");
$.fn.message('show','<div class="ok_h_message"><h2>Success</h2><p><strong>Your blog post has been added.</strong></p></div>');
setTimeout(function(){
$('#blogs-click').click();
},2000);
</script>